package com.health.trans.processor.listener;

import lombok.SneakyThrows;
import org.springframework.batch.core.ChunkListener;
import org.springframework.batch.core.scope.context.ChunkContext;

/**
 * @author nqlz
 */
public class ItemCountListener implements ChunkListener {
    @Override
    public void beforeChunk(ChunkContext context) {
        System.err.println(context.getStepContext().getStepExecution().getStepName());
    }

    @SneakyThrows
    @Override
    public void afterChunk(ChunkContext context) {
        int count = context.getStepContext().getStepExecution().getWriteCount();
        System.err.println("ItemCount: " + count);
    }

    @Override
    public void afterChunkError(ChunkContext context) {
    }
}
